home *** CD-ROM | disk | FTP | other *** search
/ Clickx 115 / Clickx 115.iso / software / tools / windows / tails-i386-0.16.iso / live / filesystem.squashfs / etc / init.d / htpdate < prev    next >
Encoding:
Text File  |  2013-01-06  |  2.2 KB  |  110 lines

  1. #! /bin/sh
  2. ### BEGIN INIT INFO
  3. # Provides:          htpdate
  4. # Default-Start:
  5. # Default-Stop:
  6. # Required-Start:    mountkernfs $local_fs
  7. # Required-Stop:
  8. # Short-Description: Set time using HTP
  9. # Description:       Set time using HTP
  10. ### END INIT INFO
  11.  
  12. DESC="Setting time using HTP"
  13. NAME=htpdate
  14. SCRIPTNAME=/etc/init.d/$NAME
  15. HTP_DIR=/var/run/$NAME
  16. PIDFILE=$HTP_DIR/pid
  17. HTP_DONE_FILE=$HTP_DIR/done
  18. HTP_SUCCESS_FILE=$HTP_DIR/success
  19. LOG=/var/log/$NAME.log
  20.  
  21. # Load the VERBOSE setting and other rcS variables
  22. . /lib/init/vars.sh
  23.  
  24. # Define LSB log_* functions.
  25. # Depend on lsb-base (>= 3.2-14) to ensure that this file is present
  26. # and status_of_proc is working.
  27. . /lib/lsb/init-functions
  28.  
  29. # Create status directory and log file
  30. install -o root -g root -m 0755 -d ${HTP_DIR}
  31. install -o htp -g nogroup -m 0644 /dev/null ${LOG}
  32.  
  33. # Source configuration
  34. . /etc/default/$NAME
  35.  
  36. log() {
  37.     echo "$@" >> "${LOG}"
  38. }
  39.  
  40. # Sanity checks
  41. if [ -z "$HTTP_USER_AGENT" ]; then
  42.     log "HTTP_USER_AGENT is not set."
  43.     exit 2
  44. fi
  45. if [ -z "$HTP_POOL_PAL" ]; then
  46.     log "HTP_POOL_PAL is not set"
  47.     exit 3
  48. fi
  49. if [ -z "$HTP_POOL_NEUTRAL" ]; then
  50.     log "HTP_POOL_NEUTRAL is not set"
  51.     exit 3
  52. fi
  53. if [ -z "$HTP_POOL_FOE" ]; then
  54.     log "HTP_POOL_FOE is not set"
  55.     exit 3
  56. fi
  57.  
  58. do_start() {
  59.     if [ -e "$HTP_DONE_FILE" ]; then
  60.         rm -f "$HTP_DONE_FILE"
  61.     fi
  62.  
  63.     if [ -e "$HTP_SUCCESS_FILE" ]; then
  64.         rm -f "$HTP_SUCCESS_FILE"
  65.     fi
  66.  
  67.     start-stop-daemon -S -q -p ${PIDFILE} -bm -x /usr/local/sbin/htpdate -- \
  68.         --debug \
  69.         --log_file "$LOG" \
  70.         --user_agent "$HTTP_USER_AGENT" \
  71.         --allowed_per_pool_failure_ratio 0.34 \
  72.         --user htp \
  73.         --done_file    "$HTP_DONE_FILE" \
  74.         --success_file "$HTP_SUCCESS_FILE" \
  75.         --pal_pool     "$HTP_POOL_PAL" \
  76.         --neutral_pool "$HTP_POOL_NEUTRAL" \
  77.         --foe_pool     "$HTP_POOL_FOE" \
  78.             --proxy        127.0.0.1:9062
  79.  
  80.     return $?
  81. }
  82.  
  83. do_stop() {
  84.     start-stop-daemon -K -q -p ${PIDFILE}
  85. }
  86.  
  87. case "$1" in
  88.   start)
  89.     [ "$VERBOSE" != no ] && log_daemon_msg "$DESC" "$NAME"
  90.     do_start
  91.     case "$?" in
  92.         0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
  93.         2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
  94.     esac
  95.     ;;
  96.   stop)
  97.     do_stop
  98.     ;;
  99.   restart)
  100.     do_stop
  101.     do_start
  102.     ;;
  103.   *)
  104.     echo "Usage: $SCRIPTNAME (start|stop|restart)" >&2
  105.     exit 3
  106.     ;;
  107. esac
  108.  
  109. :
  110.